package com.zzh.lib.core.model;


/**
 * Created by zzh on 2025/7/1.
 *
 * @date: 2025/7/1 15:08
 * @email: zzh_hz@126.com
 * @author: zzh
 * @description: com.zzh.lib.core.model
 */
public enum NetworkSecurityType {
    NONE(0),
    WPA(1),
    WPA_EAP(2),
    WPA_PSK(3),
    WPA2_EAP(4),
    WPA2_PSK(5),
    WPA3_PSK(6),
    WPA3_EAP(7),
    OPEN(8),
    WEP(9);

    private Integer code;

    NetworkSecurityType(Integer code) {
        this.code = code;
    }

    NetworkSecurityType(String desc) {
        this.code = getNetworkSecurityType(desc).code;
    }

    public Integer getCode() {
        return code;
    }

    public static NetworkSecurityType getNetworkSecurityType(String security) {
        if (security == null) {
            return NONE;
        }
        if (security.contains("WPA3-PSK")) {
            return WPA3_PSK;
        } else if (security.contains("WPA3-EAP")) {
            return WPA3_PSK;
        } else if (security.contains("WPA2-EAP")) {
            return WPA2_EAP;
        } else if (security.contains("WPA2-PSK")) {
            return WPA2_PSK;
        } else if (security.contains("WPA-EAP")) {
            return WPA_EAP;
        } else if (security.contains("WPA-PSK")) {
            return WPA_PSK;
        } else if (security.contains("WPA")) {
            return WPA;
        } else {
            return NONE;
        }
    }
}
